From: Richard M. Stallman Date: Mon, 2 Feb 1998 01:09:35 +0000 (+0000) Subject: (float_to_string): Handle infinities and NaN specially. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~78260 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=7f45de2dfc7bbfc68fd850f5ed55273f151a501d;p=emacs.git (float_to_string): Handle infinities and NaN specially. --- diff --git a/src/print.c b/src/print.c index a9c83ea821d..e3fbc393fea 100644 --- a/src/print.c +++ b/src/print.c @@ -956,6 +956,26 @@ float_to_string (buf, data) unsigned char *cp; int width; + /* Check for plus infinity in a way that won't lose + if there is no plus infinity. */ + if (data == data / 2 && data > 1.0) + { + strcpy (buf, "1.0e+INF"); + return; + } + /* Likewise for minus infinity. */ + if (data == data / 2 && data < -1.0) + { + strcpy (buf, "-1.0e+INF"); + return; + } + /* Check for NaN in a way that won't fail if there are no NaNs. */ + if (! (data * 0.0 >= 0.0)) + { + strcpy (buf, "0.0e+NaN"); + return; + } + if (NILP (Vfloat_output_format) || !STRINGP (Vfloat_output_format)) lose: